import { defineStore } from 'pinia'
import {confirmOrderList,orderlist,deleteCartItem } from '@/api/oredr'
export const useOrderStore = defineStore('useOrderStore', {
  state() {
    return {
      orderList: []
    }
  },
  //   请求
  actions: {
    // 获取结算的订单信息
   async confirmOrderListHandler(params:{userid:string,time:any}) {
        const result =await confirmOrderList(params)
        if ((result as any).code == 200) {
              this.orderList =result.data
        }
   },
    // 获取所有的订单信息
   async orderlistHandler(userid:string) {
        const result =await orderlist(userid)
        if ((result as any).code == 200) {
              this.orderList =result.data
        }
   },
    // 支付
   async deleteCartItemHandler(userid:string) {
        const result =await deleteCartItem(userid)
        if ((result as any).code == 200) {
          // 成功返回的数据
          return Promise.resolve("支付成功")
        } else {
          return Promise.reject("支付失败!")
        }
   },

   
      
    
  

   
   



  }
})
